<?php
/**
* $Header: /cvsroot/phpbinder/binder/update_records.php,v 1.9 2004/07/22 04:49:55 vidluther Exp $
* +----------------------------------------------------------------------+
* | $Revision: 49 $                                                         |
* +----------------------------------------------------------------------+
* | Copyright (c) 2000-2004 Linuxpowered, Inc                            |
* +----------------------------------------------------------------------+
* | Author: Vidyut Luther <vid@linuxpowered.com>                         |
* +----------------------------------------------------------------------+
* 
**/
 require_once('./global.inc.php') ; 
  require_once(INCLUDE_PATH."/Records.class.php") ; 


global $_SESSION; 
$record_id = $_GET['id']; 
$action = $_GET['action'];
$wdom = $_SESSION['workingdomain']; 



switch($action) {
  case 'edit':
    $r = new DNSRecord(); 
    $rtypes = $r->mLoadTypes();
    /* now get all the records for the domain we're looking at */
    $r->mSetId($record_id);

    $domRecords = $r->mLoadRecordsById();

    $type = $domRecords[0][rtype] ; 
    $tpl->assign("rid",$record_id); 
    $tpl->assign("seltype",$type) ; 
    $tpl->assign("dnsRecords",$domRecords); 
    $tpl->assign("rtypes",$rtypes); 
    $tpl->display("edithosts.html"); 
    break;
  case 'delete':
    $sql = "DELETE FROM records where record_id='$record_id'"; 
    $db->mInsert($sql); 
    header("Location: manage.php"); 
    break;
  case 'deletemultiple':
    $checkid = $_GET['checkid']; 
    $start = "BEGIN WORK "; 
    $db->mInsert($start); 
    $sql = "DELETE FROM records WHERE record_id IN (". implode(',',$checkid) . ")" ;
    $db->mInsert($sql); 
    if($db->strError) {
      $end = "ROLLBACK "; 
    } else {
      $end = "COMMIT"; 
    }
    $db->mInsert($end); 
    header("Location: manage.php"); 
    break;
  case 'Change IPs':
    $newip = $_GET['newmultipleip'];
    $checkid = $_GET['checkid']; 
    if(!empty($checkid)) { 
      $records = implode(',',$checkid); 
   
      $start = "BEGIN WORK "; 
      $db->mInsert($start); 
      $sql = "UPDATE records SET hostip=INET_ATON('$newip') WHERE record_id IN ($records) AND rtype <> 'CNAME' "; 
      $db->mInsert($sql); 
      if($db->strError) {
        $end = "ROLLBACK "; 
      } else {
        $end = "COMMIT"; 
      }
      $db->mInsert($end); 
      header("Location: manage.php"); 
      exit();
    } else { 
      $errMsg = "You did not select any Records to update "; 
      trigger_error($errMsg);
      exit();    
    }
    break;
  default: 
    header("Location: manage.php"); 
    break;
}



?>
